<template>
    <div style="height: 100%;">
        <content-container >
            <carousel
                v-for="(item, index) in pageTree.content[type.Carousel]" 
                :key="index" :bannerid="item.id"
                v-sdrag:real="{id: item.id, com: item.id, type: type.Carousel}">
            </carousel>
            <user-card v-for="(item, index) in pageTree.content[type.UserCard]" :key="index"
                v-sdrag:real="{id: item.id, com: item.id, type: type.UserCard}">
            </user-card>
        </content-container>
    </div>
</template>
<script>
    import ContentContainer from "../../../real-components/ContentContainer";
    import Carousel from "./Carousel";
    import UserCard from "./UserCard";
    //引用配置文件
    import * as prefix from "../../../config/page-name/gw/virtualpagename-prefix";
    import {getPageNameOrVirtualPageName} from "../../../utils/getPageName";
    import getPageName from "../../../utils/getPageName";
    import {getPageTree, initDomTree} from "../../../utils/getPageTree";
    export default {
        data() {
            return {
                type: {
                    Carousel: "HomeCarousel",
                    UserCard: "UserCard"
                }
            }
        },
        computed: {
            pageName() {
                return getPageNameOrVirtualPageName();
            },
            currentVDO() {
                return "";
            },
            activeIndex() {
                return this.$store.state.cjy.classifyIndex;
            },
            currentVirtualPageName() {
                return this.pageName + prefix.SELF_PAGE + (this.activeIndex + 1);
            },
            defaultVirtualDomObject() {
				return {
					header: [],
					content: [],
					footer: [],
                    config: {}
				}
			},
            pageTree() {
                return Object.keys(getPageTree(this, this.pageName)).length ? getPageTree(this, this.pageName) : this.defaultVirtualDomObject;
            }
        },
        methods: {

        },
        components: {
            "content-container": ContentContainer,
            "carousel": Carousel,
            UserCard
        },
        created() {
            // console.log("created-0-0-0-0-0-0-0-0-0", this.currentVirtualPageName);
            // console.log("dfdfdfdfd", this.currentVirtualPageName);
            
			// this.$store.commit("gw/setVirtualPageName", this.currentVirtualPageName);
        },
        mounted() {
            initDomTree(this.$store.getters.getDomTree[this.pageName]);
            this.$store.commit("setFirstInitDom", {
                header: this.currentVirtualPageName + "-header",
                footer: this.currentVirtualPageName + "-footer",
                content: this.currentVirtualPageName + "-content",
            });
			//设置对应的虚拟页面
			// this.$store.commit("gw/setVirtualPageName", "gwTestselfpage" + (this.activeIndex + 1));
            this.$store.commit("gw/setVirtualPageName", this.currentVirtualPageName);
        },
        updated() {
            initDomTree(this.$store.getters.getDomTree[this.pageName]);
        },
        beforeDestroy() {
            // console.log("beforeDestroy-0-0-0-0-0-0-0-0-0", this.currentVirtualPageName);
            this.$store.commit("setFirstInitDom", {
                header: "",
                footer: "",
                content: "",
            });
            this.$store.commit("gw/setVirtualPageName", "");
        }
    }
</script>
<style scoped>
</style>

